1f81d386299b723e536a57d48b4b2fdd0788fb13,src/main/org/codehaus/groovy/transform/stc/StaticTypeCheckingVisitor.java,StaticTypeCheckingVisitor,visitForLoop,#ForStatement#,727
Before Change
// visit body
Map<VariableExpression, List<ClassNode>> oldTracker = pushAssignmentTracking();
final ClassNode collectionType = getType(forLoop.getCollectionExpression());
ClassNode componentType = inferLoopElementType(collectionType);
forLoopVariableTypes.put(forLoop.getVariable(), componentType);
if (!checkCompatibleAssignmentTypes(forLoop.getVariableType(), componentType)) {
addStaticTypeError("Cannot loop with element of type " + forLoop.getVariableType() + " with collection of type " + collectionType, forLoop);
}
After Change
// visit body
Map<VariableExpression, List<ClassNode>> oldTracker = pushAssignmentTracking();
Expression collectionExpression = forLoop.getCollectionExpression();
if (collectionExpression instanceof ClosureListExpression) {
// for (int i=0; i<...; i++) style loop
super.visitForLoop(forLoop);
} else {
final ClassNode collectionType = getType(collectionExpression);
ClassNode componentType = inferLoopElementType(collectionType);
forLoopVariableTypes.put(forLoop.getVariable(), componentType);
if (!checkCompatibleAssignmentTypes(forLoop.getVariableType(), componentType)) {
addStaticTypeError("Cannot loop with element of type " + forLoop.getVariableType() + " with collection of type " + collectionType, forLoop);
}